import 'package:flutter/material.dart';

class ChangeViewApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'change View',
      theme: new ThemeData(primaryColor: Colors.amberAccent[400]),
      home: new CVWidget(),
    );
  }
}

class CVWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new CVState();
  }
}

class CVState extends State<CVWidget> {
  bool isSelect = false;

  void changeState() {
    setState(() {
      isSelect = !isSelect;
    });
  }

  Widget _getWidgetByState() {
    if (isSelect) {
      return new MaterialButton(
        onPressed: null,
        child: new Text('matrial btn'),
      );
    } else {
      return new Text('txt only');
    }
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('change view'),
      ),
      body: new Center(
        child: _getWidgetByState(),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: changeState,
        child: new Icon(Icons.change_history),
        tooltip: 'change',
      ),
    );
  }
}
